package com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor;

import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.Cancel;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.Detector;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.FixedLink;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.Name;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.RecordId;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.Resource;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.Save;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.guide.editor.form.Tag;
import com.gwtext.client.core.Ext;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.layout.AnchorLayoutData;

public final class Form extends FormPanel {

	public Form() {
		super();
		this.setId(Form.class.getName());
		
		this.setBaseCls("x-plain");
		this.setPaddings(15);
		this.add(new Name(), new AnchorLayoutData("95%"));
		this.add(new Detector(), new AnchorLayoutData("95%"));
		this.add(new Resource(), new AnchorLayoutData("95%%"));
		this.add(new FixedLink(), new AnchorLayoutData("95%%"));
		this.add(new Tag(), new AnchorLayoutData("95%%"));
		this.add(new RecordId());
		this.addButton(new Save());
		this.addButton(new Cancel());
	}
	
	public void edit(String recordId, String name, String detector, String resource, String fixedLink, String tag) {
		((RecordId) Ext.getCmp(RecordId.class.getName())).setValue(recordId);
		((Name) Ext.getCmp(Name.class.getName())).setValue(name);						
		((Detector) Ext.getCmp(Detector.class.getName())).setValue(detector);						
		((Resource) Ext.getCmp(Resource.class.getName())).setValue(resource);
		((FixedLink) Ext.getCmp(FixedLink.class.getName())).setValue(fixedLink);
		((Tag) Ext.getCmp(Tag.class.getName())).setValue(tag);
	}
	
}
